package com.mobibom.pipelines;

import pipelines.free.beta.R;

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.KeyEvent;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class HowToPlayActivity extends Activity {
	Button previous,next;
	TextView text;
	
	ImageView plaatje;
	
	int page;
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.howtoplayview);
	    page = 1;
	    
	    setViews();
	    plaatjewisselfunction();
	}
	private void plaatjewisselfunction(){
		plaatje.setBackgroundResource(R.drawable.howtoplay2);
		
		new CountDownTimer(6000, 1000) {

		     public void onTick(long millisUntilFinished) {
		    	if(millisUntilFinished == 0){
		    		//plaatje 1
		    	}
		    	else if(millisUntilFinished < 2000){
		    		plaatje.setBackgroundResource(R.drawable.howtoplay5);
		    	}
		    	else if (millisUntilFinished < 3000){
		    		plaatje.setBackgroundResource(R.drawable.howtoplay4);
		    	}
		    	else if( millisUntilFinished < 4000){
		    		plaatje.setBackgroundResource(R.drawable.howtoplay3);
		    	}
		    	else if( millisUntilFinished < 5000){
		    		plaatje.setBackgroundResource(R.drawable.howtoplay2);
		    	}
		     }

		     public void onFinish() {
		    	 plaatjewisselfunction();
		     }
		  }.start();
	}
	
	private void setViews() {
	//	previous = 		(Button)findViewById(R.id.buttonHowToPlayPrevious);
	//	next = 			(Button)findViewById(R.id.buttonHowToPlayNext);
		
	//	text = 			(TextView)findViewById(R.id.textViewHowToPlayText);
		
		plaatje = 		(ImageView)findViewById(R.id.imageviewHowToPlay);
		//advertentie
		 // Lookup R.layout.main
        LinearLayout layout = (LinearLayout)findViewById(R.id.layoutAdsHowToPlay);
        // Create the adView
        AdView adView1;
    	final String MY_BANNER_UNIT_ID = "a14ed7bde839b79";
        // Please replace MY_BANNER_UNIT_ID with your AdMob Publisher ID
        adView1 = new AdView(this, AdSize.BANNER, MY_BANNER_UNIT_ID);
        // Add the adView to it
        layout.addView(adView1);
        // Initiate a generic request to load it with an ad
        AdRequest request = new AdRequest();
        //request.setTesting(true);
        adView1.loadAd(request);       
	}
	@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK)) {
        	Intent start = new Intent(getApplicationContext(), StartScreenActivity.class);
    		startActivity(start);
    		this.finish();
        }
        return super.onKeyDown(keyCode, event);
    }
}
